home *** CD-ROM | disk | FTP | other *** search
- // JScript source code
-
- // parameter values used
- var strTotalDays = "TotalDays";
- var strUsedDays = "NumDays";
-
- // rgb colour values
- var strRed = "red";
- var strGrn = "green";
- var strRedRGB = "rgb(184,29,3)"
- var strGrnRGB = "rgb(31,156,35)";
-
- // standard graphics paths for single pixel border graphics
- var strBdrRed = "url('Images\\TrialCounter\\red1.png')";
- var strBdrGrn = "url('Images\\TrialCounter\\green1.png')";
-
- // standard graphics paths for box corners
- var strBasePath = "Images\\TrialCounter\\";
- var strTL = "_t_l.gif";
- var strTR = "_t_r.gif";
- var strBL = "_b_l.gif";
- var strBR = "_b_r.gif";
-
- function reLayout(strURL)
- {
- // only do this if the counter is to be shown
- var strShow = extractParam(strURL, "ShowCounter");
- if(strShow.toLowerCase() == "yes")
- {
- // show the count
- var tdPromo = document.getElementById("tdPromo")
- if (tdPromo != null)
- {
- tdPromo.style.display = "";
- }
- var divTrialRemain = document.getElementById("divTrialRemain")
- if (divTrialRemain != null)
- {
- divTrialRemain.style.display = "";
- }
-
- var divCount1 = document.getElementById("divCountBottom1");
- var divCount2 = document.getElementById("divCountBottom2");
- if ((divCount1 != null) && (divCount2 != null))
- {
- var strST = extractParam(strURL, "ST");
- if ((strST == "1") || (strST == "3"))
- {
- divCount1.style.display = "none";
- divCount2.style.display = "";
- }
- }
-
-
- var elmCount = document.getElementById("divCountDown");
-
- // get the values for the trail total and trial remaining
- var strTrialTotal = extractParam(strURL,strTotalDays);
- var strDaysRemain = extractParam(strURL,strUsedDays);
-
- // get an int value for each number
- var nTrialTotal = 0;
- if(strTrialTotal.length > 0)
- {
- nTrialTotal = parseInt(strTrialTotal,10);
- }
- var nDaysRemain = 0;
- if(strDaysRemain.length > 0)
- {
- nDaysRemain = parseInt(strDaysRemain,10);
- }
- if (nDaysRemain < 0)
- {
- nDaysRemain = 0;
- }
-
- // insert the days remaining into the document
- var elmCounter = document.getElementById("divCount");
- if(null != elmCounter)
- {
- elmCounter.innerText = String(nDaysRemain);
- }
-
- // adust the size of the progress bar
- var elmTopSlider = document.getElementById("divOverSlider");
- var elmBotSlider = document.getElementById("divUnderSlider");
- if(nTrialTotal > 0)
- {
- if(null != elmTopSlider)
- {
- // get the days remaining as a percentage
- var nPercent = (nDaysRemain / nTrialTotal);
- if(nPercent > 1)
- {
- nPercent = 1;
- }
-
- // get the total length of the progress bar and computer the desired
- // length of the slider
- if(null != elmBotSlider)
- {
- var nTotalWidth = parseInt(elmBotSlider.offsetWidth);
- var nPartWidth = (nTotalWidth * nPercent);
- elmTopSlider.style.width = String(nPartWidth);
- }
- }
- }
-
- // remove the progress bar
- if((nTrialTotal == 0) )
- {
- if((null != elmCount) && (null != elmTopSlider) && (null != elmBotSlider))
- {
- // remove the progress bar from the DOM
- var elmPImgLeft = document.getElementById("divPBStart");
- var elmPImgRight = document.getElementById("dibPBEnd");
- if(null != elmPImgLeft)
- {
- elmTopSlider.removeChild( elmPImgLeft );
- }
- if(null != elmPImgRight)
- {
- elmTopSlider.removeChild( elmPImgRight );
- }
-
- elmBotSlider.removeChild( elmTopSlider );
- elmCount.removeChild( elmBotSlider );
- }
- }
-
- // we now have to change the colour of several elements as well as swap some graphics
- var strColour = strGrn;
- var strColourRGB = strGrnRGB; // initial RGB colour
- var strPixel = strBdrGrn; // initial single pixel border
- if( nDaysRemain == 0 )
- {
- strColour = strRed;
- strColourRGB = strRedRGB;
- strPixel = strBdrRed;
- }
-
- // change the colour of the numerical text
- elmCounter.style.color = strColourRGB;
-
- // hook up the border graphics for the straight part of the border
- var elmTop = document.getElementById("bdrTop");
- var elmLft = document.getElementById("bdrLft");
- var elmBtm = document.getElementById("bdrBtm");
- var elmRgt = document.getElementById("bdrRgt");
-
- if(null != elmTop)
- {
- elmTop.style.backgroundImage = strPixel;
- }
- if(null != elmLft)
- {
- elmLft.style.backgroundImage = strPixel;
- }
- if(null != elmBtm)
- {
- elmBtm.style.backgroundImage = strPixel;
- }
- if(null != elmRgt)
- {
- elmRgt.style.backgroundImage = strPixel;
- }
-
- // hook up the graphics for the box corner
- var elmCnrTL = document.getElementById("cnrTL");
- var elmCnrTR = document.getElementById("cnrTR");
- var elmCnrBL = document.getElementById("cnrBL");
- var elmCnrBR = document.getElementById("cnrBR");
-
- if(null != elmCnrTL)
- {
- elmCnrTL.style.backgroundImage = ("url(" + strBasePath.concat(strColour.concat( strTL )) + ")");
- }
- if(null != elmCnrTR)
- {
- elmCnrTR.style.backgroundImage = ("url(" + strBasePath.concat(strColour.concat( strTR )) + ")");
- }
- if(null != elmCnrBL)
- {
- elmCnrBL.style.backgroundImage = ("url(" + strBasePath.concat(strColour.concat( strBL )) + ")");
- }
- if(null != elmCnrBR)
- {
- elmCnrBR.style.backgroundImage = ("url(" + strBasePath.concat(strColour.concat( strBR )) + ")");
- }
- }
- else
- {
- var tdPromo = document.getElementById("tdPromo")
- if (tdPromo != null)
- {
- tdPromo.style.display = "none";
- }
- var divTrialRemain = document.getElementById("divTrialRemain")
- if (divTrialRemain != null)
- {
- divTrialRemain.style.display = "none";
- }
- }
- }
-
- function ShowBanner(strShow)
- {
- var bannerTop = document.getElementById("bannerTop");
- var bannerCenter = document.getElementById("bannerCenter");
- var bannerBottom = document.getElementById("bannerBottom");
- if ((bannerTop != null) && (bannerCenter != null) && (bannerBottom != null))
- {
- if ( strShow.toLowerCase() == "no" )
- {
- bannerTop.style.display = "none";
- bannerCenter.style.display = "none";
- bannerBottom.style.display = "none";
- }
- else
- {
- bannerTop.style.display = "inline";
- bannerCenter.style.display = "inline";
- bannerBottom.style.display = "inline";
- }
- }
- }
-
- function SetActivationCodeElement()
- {
- var strActCode = getParamVal("activationcode");
- var oTxt = document.getElementById("txtActivationCode");
-
- if (strActCode != null && oTxt != null)
- oTxt.value = strActCode.toUpperCase();
- }
-
- function getParamString()
- {
- var sParamString = "";
- var sQueryVar = location.search;
- var nIndex = sQueryVar.indexOf("?");
- if ( nIndex >= 0 )
- {
- sParamString = sQueryVar.substr(nIndex);
- }
-
- return sParamString;
- }
-
- function getParamVal(paramName)
- {
- var sQueryVar = location.search.toLowerCase();
- return extractParam(sQueryVar, paramName);
- }
-
- function extractParam(sQueryVar, paramName)
- {
- if (sQueryVar == null || paramName == null)
- return "";
-
- var nIndex = sQueryVar.indexOf("?");
- if (nIndex >= 0)
- sQueryVar = sQueryVar.substr(nIndex + 1);
-
- paramName = paramName.toLowerCase();
-
- var asParams = sQueryVar.split("&");
- var i;
-
- for (i in asParams)
- {
- var pair = asParams[i].split("=");
- if (pair.length == 2)
- {
- if (pair[0].toLowerCase() == paramName)
- {
- return pair[1];
- }
- }
- }
-
- return "";
- }
-
- function EnableContinue(bEnable)
- {
- var oBtn = document.getElementById("btnContinue");
- if (oBtn != null)
- {
- oBtn.disabled = (bEnable == false);
- }
- }
-
- function ExpandRelativeURL(sPage)
- {
- var sPath = location.pathname;
- var lastbkslsh = sPath.lastIndexOf("\\");
- if (lastbkslsh < 0)
- {
- lastbkslsh = sPath.lastIndexOf("/");
- }
- if (lastbkslsh < 0)
- {
- lastbkslsh = 0;
- }
- sPath = sPath.substr(0, lastbkslsh + 1);
- var sReturn = location.protocol + "//" + location.host + sPath + sPage;
- return sReturn;
- }
-
- function ValidateSerial(sSerial)
- {
- if (sSerial != null && sSerial.match(/^\s*[a-zA-Z]{2}\d{2}[a-zA-Z]{3}-?\d{7}-?[a-zA-Z]{3}(?:\*\d{6})?\s*$/) != null)
- {
- return true;
- }
- return false;
- }
-
- function ValidateActCode(sCode)
- {
- if (sCode != null && sCode.match(/^\s*(?:[a-fA-F0-9]{4}-?){5}\s*$/) != null)
- {
- return true;
- }
-
- return false;
- }
-
- function FormatSerial(sCode)
- {
- if (sCode != null && sCode.length >= 17 && sCode.indexOf("-") == -1)
- {
- var sNewCode = sCode.substr(0,7) + "-" + sCode.substr(7,7) + "-" + sCode.substr(14);
- sNewCode = sNewCode.toUpperCase();
- return sNewCode;
- }
- else
- {
- return sCode;
- }
- }
-
- function FormatActivationCode(sCode)
- {
- if (sCode != null && sCode.length == 20 && sCode.indexOf("-") == -1)
- {
- var sNewCode = sCode.substr(0,4) + "-" + sCode.substr(4,4) + "-" +
- sCode.substr(8,4) + "-" + sCode.substr(12,4) + "-" + sCode.substr(16,4);
- sNewCode = sNewCode.toUpperCase();
- return sNewCode;
- }
- else
- {
- return sCode;
- }
- }
-
-
- function regChangeLaunchButtonTitle()
- {
- var btnClose = document.getElementById("btnClose");
- if ( btnClose != null )
- {
- btnClose.style.display = "inline";
-
- var btnLaunch = document.getElementById("btnLaunch");
- if ( btnLaunch != null )
- {
- btnLaunch.style.display = "none";
- }
- }
- }
-
- function OnUnlock()
- {
- location='pcucmd://Unlock?admin=yes';
- location='pcucmd://Next?condition=true'
- }
-